package benworks.bookcode.jvm.chapter3;

/**
 * testGC 方法执行后，objA 和 objB 会不会被执行呢？
 * 
 * @author liubin
 *
 */
public class ReferenceCountingGC {

	public Object instance =  null;
	
	private static final int _1MB = 1024 * 1024;
	
	private byte[] bigSize =  new byte[2 * _1MB];
	
	public static void testGC() {
		ReferenceCountingGC objA = new ReferenceCountingGC();
		ReferenceCountingGC objB = new ReferenceCountingGC();
		objA.instance = objB;
		objB.instance = objA;
		
		objA = null;
		objB = null;
		
		//假设在这行发生GC,那么objA和objB是否能被回收？
		System.gc();
	}
}
